package kugou

import (
	"api-go/serializer"
	"api-go/util"
)

// MV所需信息
type MV struct {
	Offset string `form:"offset"`
	Id     string `form:"id"`
	Limit  string `form:"limit"`
}

//获取MV列表
func (service *MV) MVList() *serializer.Response {

	if val := service.Offset; val != "" {
		service.Offset = val
	} else {
		service.Offset = "1"
	}

	if val := service.Limit; val != "" {
		service.Limit = val
	} else {
		service.Limit = "30"
	}

	url := "http://mobilecdnbj.kugou.com/api/v5/video/list?version=9108&plat=0&pagesize=" + service.Limit + "&id=0&page=" + service.Offset + "&sort=4&short=0"

	res, err := util.Get(url)
	if err != nil {
		return err
	}
	return serializer.OkResponse(res)
}

//获取MV信息
func (service *MV) MVInfo() *serializer.Response {

	//此处Id实则为hash
	if val := service.Id; val != "" {
		service.Id = val
	} else {
		service.Id = "9e3d2a35f5df098417b3b61db4a67e37"
	}

	url := "https://m.kugou.com/app/i/mv.php?cmd=100&ismp3=1&ext=mp4&hash=" + service.Id

	res, err := util.Get(url)
	if err != nil {
		return err
	}
	return serializer.OkResponse(res)
}
